﻿using MediatR;
using W.Common.Enum;
using W.Device.API.Application.Command;
using W.Device.Repository.Interface;

namespace W.Device.API.Application.CommandHandlder
{
    public class DeviceUpdateCommandHandler : IRequestHandler<DeviceUpdateCommand, int>
    {
        private readonly IDeviceRepository deviceRepository;

        public DeviceUpdateCommandHandler(IDeviceRepository deviceRepository)
        {
            this.deviceRepository = deviceRepository;
        }

        public async Task<int> Handle(DeviceUpdateCommand request, CancellationToken cancellationToken)
        {
            return await deviceRepository.Update(new Domain.DevicesInfo() { DeviceId = request.DeviceId, DeviceNo = request.DeviceNo, DeviceName = request.DeviceName, DeviceAccreNo = request.DeviceAccreNo, IsAccre = request.IsAccre, DeviceStatus = request.DeviceStatus, DeviceRemarks = request.DeviceRemarks, CreateName = request.CreateName, CreateTime = request.CreateTime, UpdateName = request.UpdateName, UpdateTime = request.UpdateTime, DeleteName = request.DeleteName, DeleteTime = request.DeleteTime, IsDelete = request.IsDelete });
        }
    }
}
